//
//  llCollectionViewCell.m
//  豆瓣电影app
//
//  Created by 洛洛大人 on 16/6/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "llCollectionViewCell.h"
#import "MovieModel.h"
#import "LlViewController.h"
#import "UIImageView+WebCache.h"
@interface llCollectionViewCell()
@property(nonatomic, retain)UIImageView *leoImageView;
@property(nonatomic, retain)UILabel *leoLabel;

@end


@implementation llCollectionViewCell

-(void)dealloc{
    [_leoImageView release];
    [_leoLabel release];
    [super dealloc];
    
    
}

-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.leoImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.leoImageView];
        
        self.leoLabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.leoLabel];
        
        
        [self.leoLabel release];
        [self.leoImageView release];
        
        
    }
    return self;
    
}


-(void)layoutSubviews {
    
    [super layoutSubviews];
    
    
    self.leoImageView.frame = self.contentView.bounds;
    
    self.leoLabel.frame = CGRectMake(self.contentView.frame.size.width - 100, self.contentView.frame.size.width + 40, 100, 50);
   
    self.leoLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;


}


-(void)setCellModel:(MovieModel *)cellModel {
    
    if(_cellModel != cellModel) {
        
        [_cellModel release];
        _cellModel = [cellModel retain];
    }
    
    self.leoLabel.text = cellModel.movieName;
    
    
    NSURL *url = [NSURL URLWithString:cellModel.pic_url];
    //    NSData *data = [NSData dataWithContentsOfURL:url];
    //    UIImage *image = [UIImage imageWithData:data];
    //    self.leoImageView.image = image;
    //
    [self.leoImageView sd_setImageWithURL:url];
    
}



@end

